package com.wogu.jwa.classes;

import javax.servlet.ServletContextListener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContext;

import org.apache.log4j.PropertyConfigurator;

import com.wogu.jwa.classes.AppConfig;

public class JwaServletContextListener implements ServletContextListener {
	
	public void contextInitialized(ServletContextEvent sce) {
		ServletContext sc = sce.getServletContext();
		//init log4j
		String fileName = sc.getInitParameter("log4j-init-file");
		String path = sc.getRealPath("/WEB-INF/" + fileName);
		PropertyConfigurator.configure(path);
		//init AppConfig
		AppConfig.init(sc);
	}
	
	public void contextDestroyed(ServletContextEvent sce) {
		AppConfig.destroy();
	}
}